# altermailbox
from tkinter import *
from pathlib import Path

OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("img")
def relative_to_assets(path: str) -> Path:
    return ASSETS_PATH / Path(path)
class Altermailbox():

    def __init__(self):
        self.root = Tk()
        self.root.title("修改邮箱")
        self.root.config(background="white")
        self.root.resizable(0, 0)
        root_height = 350
        root_width = 460
        sx = self.root.winfo_screenwidth()
        sy = self.root.winfo_screenheight()
        cw_x = (sx - root_width) / 2
        cw_y = (sy - root_height) / 2
        self.root.geometry("%dx%d+%d+%d" % (root_width, root_height, cw_x, cw_y))

        photo0 = PhotoImage(file=relative_to_assets("photo23.png"))

        self.canvas_top = Canvas(
            self.root,
            bg="white",
            height=2,
            width=180,
            bd=0,
            highlightthickness=0,
            relief="ridge",
        )
        self.canvas_top.pack(side=TOP, fill=Y)
        Label(self.canvas_top,text = "修改邮箱", font=("宋", 15, "bold"), fg="#32CDFA",bg = "white").grid(row=0, column=0,
                                                                                           pady = 15)
        Canvas(self.canvas_top,bg ="#32CDFA" ,width = 320,height = 2,relief="ridge" ,bd = 0,highlightthickness=0,).grid(row=1, column=0,
                                                                                           )
        frame0 = Frame(self.root, bg="white", relief="flat", height=20, width=20)
        frame0.pack(side=TOP, fill=Y,pady = 10)
        self.mailbox_l0 = Label(frame0,text = "1.邮箱验证",bg ="#32CDFA",fg = "white" )
        self.mailbox_l0.grid(row = 0,column = 0)
        Label(frame0,image = photo0,bg = "white").grid(row = 0,column = 1)
        self.pass_l0 = Label(frame0,text = "2.绑定新邮箱",bg = "#9bd6f4",fg = "white" )
        self.pass_l0.grid(row = 0,column = 2)

        self.canvas_top_1 = Canvas(
            self.root,
            bg="white",
            height=2,
            width=180,
            bd=0,
            highlightthickness=0,
            relief="ridge",
        )
        self.canvas_top_1.pack(side=TOP, fill=Y,pady = 20)

        mailbox_l = Label(self.canvas_top_1,bg = "white" , fg = "#32CDFA",text = "邮    箱:",width = 8)
        mailbox_l.grid(row = 0,column = 0,pady = 10,padx = 15)
        code_l = Label(self.canvas_top_1,bg = "white" , fg = "#32CDFA",text = "验证码:",width = 8)
        code_l.grid(row = 1,column = 0,pady = 10,padx = 15)

        code_e= Entry(self.canvas_top_1, bd=3, )
        code_e.grid(row=0, column=1, pady=10, padx=15)
        mailbox_f = Frame(self.canvas_top_1, bg="white", relief="flat", height=20, width=20)
        mailbox_f.grid(row=1, column=1)



        Entry(mailbox_f, bd = 3,width = 15).pack(side = LEFT,fill = Y)

        Button(mailbox_f,bg = "#32CDFA",fg = "white",text = "发送",relief="flat",bd = 0).pack(side = LEFT,fill = Y,padx = 3)
        next_b = Button(self.canvas_top_1,bg = "#32CDFA",fg = "white",text = "下一步",relief="flat",bd = 0,width = 20,command = self.resetpass)
        next_b.grid(row = 4,column = 0,columnspan=2,pady = 5)

        self.aal = [mailbox_l,code_l,code_e,mailbox_f,next_b]





        self.root.mainloop()


    def resetpass(self):
        self.mailbox_l0.config(bg = "#9bd6f4")
        self.pass_l0.config(bg = "#32CDFA")

        for i in self.aal:
            i.grid_forget()

        mailbox_l = Label(self.canvas_top_1, bg="white", fg="#32CDFA", text="邮    箱:", width=8)
        mailbox_l.grid(row=0, column=0, pady=10, padx=15)
        code_l = Label(self.canvas_top_1, bg="white", fg="#32CDFA", text="验证码:", width=8)
        code_l.grid(row=1, column=0, pady=10, padx=15)

        code_e = Entry(self.canvas_top_1, bd=3, )
        code_e.grid(row=0, column=1, pady=10, padx=15)
        mailbox_f = Frame(self.canvas_top_1, bg="white", relief="flat", height=20, width=20)
        mailbox_f.grid(row=1, column=1)

        Entry(mailbox_f, bd=3, width=15).pack(side=LEFT, fill=Y)

        Button(mailbox_f, bg="#32CDFA", fg="white", text="发送", relief="flat", bd=0).pack(side=LEFT, fill=Y, padx=3)
        next_b = Button(self.canvas_top_1, bg="#32CDFA", fg="white", text="确认修改", relief="flat", bd=0, width=20,
                        command=self.resetpass)
        next_b.grid(row=4, column=0, columnspan=2, pady=5)




if __name__ == "__main__":
    Altermailbox()
